package com.sherlocky.resource.dto;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;
import org.directwebremoting.annotations.DataTransferObject;

import com.rework.core.dto.BaseObject;
import com.sherlocky.resource.common.ResourceContants;

/**
 * 对应resource表 存储内容包括附件和在线编辑的长文本文档等的内容.
 * */

@DataTransferObject
public class ResourceDTO extends BaseObject implements Serializable{

	private static final long serialVersionUID = -3809101952047554544L;
	/** 转码标识：尚未转码 */
	public static final int TRANS_FLAG_NOT = 0;
	/** 转码标识：成功转码 */
	public static final int TRANS_FLAG_SUCCESS = 1;
	/** 转码标识：转码失败 */
	public static final int TRANS_FLAG_ERROR = 2;
	/** 转码处理中*/
	public static final int TRANS_FLAG_ING = 3;
	
	/** 转换页面为图片 */
	public static final int TRANS_PAGE2IMAGE = 1;
	
	private Long id;
	/**附件路径*/
	private String filepath;
	private Long size;
	/**文件后缀*/
	private String suffix;
	/**转码文件路径*/
	private String  transfilePath;
	/**缩略图路径*/
	private String transpicPath;
	/**文件所属类型，如：图片、文档、音频、视频、文本文件、附件等*/
	private String fileType;
	/**存储长文本资源,如在线编辑的文档内容等*/
	private String resourceContent;
	/**生成时间*/
	private Integer dateline;
	/**文件MD5*/
	private String md5;
	/**最后修改时间*/
	private Integer lastModifyTime;
	/**学校ID*/
	private Long schoolId;
	/** 视频或音频的时长（单位：秒） */
	private Integer duration;
	/** 是否已转码 */
	private Integer transFlag;
	/**来源*/
	private String source;
	/*资源名称*/
	private String resourceName;
	/*资源模块--为了资源对应模块而冗余*/
	private Long moduleTypeId;
	private String moduleType;
	private Long resourceModuleId;
	private Long uid;//作者
	private String name;//作者姓名
	private Integer likeCount;//喜欢次数
	private Integer commentCount;//评论数
	private Integer love;//当前用户是否喜欢
	//not in db 针对班级学生观看次数
	private Integer num;
	//资源点击量
	private Integer clicks;
	/**描述*/
	private String description;
	
	/** 背景音乐对应的资源id，图说的资源会用到 */
	private Integer bgMusic;
	//下载权限标识 @ResourceModuleDTO 字段
	private String downloadPower;
	private Integer sysExtra;
	/**实际上传时间,取的是resource_module表中的时间*/
	private Integer mdateline;
	/**	  视频编码	 */
	private String code;
	/** 视频源信息*/
	private String metainfo;
	
	/** OSS 相关*/
	private Integer ossServer; // 是否保存到OSS 1-是 0-否
	private String ossDomain;
	private String ossBucket;  // OSS存储的bucket
	private String ossTransId; // OSS转码持久化id
	private String ossTransKey; // OSS转码文件key
	private String ossHash;    // OSS文件HASH
	/** oss文件路径 */
	private String ossPath;
	private String playPath; // 播放路径
	/** 是否转码成图片，默认是文件所在文件路径下pages下存放（一页一张图片） */
	private Integer page2image;

	/**是否为已经上传的文件*/
	private boolean hasAlreadyExists = false;
	
	public ResourceDTO(){
		
	}
	
	public ResourceDTO(String ossHash, String key, String domain, Long size, String suffix, String fileType){
		this.size = size;
		this.ossHash = ossHash;
		this.ossPath = key;
		this.ossDomain = domain;
		this.suffix = suffix;
		this.fileType = fileType;
	}
	
	public Integer getLikeCount() {
		return likeCount;
	}

	public void setLikeCount(Integer likeCount) {
		this.likeCount = likeCount;
	}

	public Integer getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(Integer commentCount) {
		this.commentCount = commentCount;
	}

	public Integer getLove() {
		return love;
	}

	public void setLove(Integer love) {
		this.love = love;
	}

	public String getModuleType() {
		return moduleType;
	}
	public void setModuleType(String moduleType) {
		this.moduleType = moduleType;
	}
	
	
	public Long getUid() {
		return uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getNum() {
		return num;
	}
	public Integer getClicks() {
		return clicks;
	}

	public void setClicks(Integer clicks) {
		this.clicks = clicks;
	}

	public void setNum(Integer num) {
		this.num = num;
	}
	public Long getResourceModuleId() {
		return resourceModuleId;
	}
	public void setResourceModuleId(Long resourceModuleId) {
		this.resourceModuleId = resourceModuleId;
	}
	public Long getModuleTypeId() {
		return moduleTypeId;
	}
	public void setModuleTypeId(Long moduleTypeId) {
		this.moduleTypeId = moduleTypeId;
	}
	public String getResourceName() {
		return resourceName;
	}
	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getFilepath() {
		return filepath;
	}
	public void setFilepath(String filepath) {
		this.filepath = filepath;
	}
	public Long getSize() {
		return size;
	}
	public void setSize(Long size) {
		this.size = size;
	}
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	public String getTransfilePath() {
		return transfilePath;
	}
	public void setTransfilePath(String transfilePath) {
		this.transfilePath = transfilePath;
	}
	public String getTranspicPath() {
		return transpicPath;
	}
	public void setTranspicPath(String transpicPath) {
		this.transpicPath = transpicPath;
	}
	public String getFileType() {
		return fileType;
	}
	public void setFileType(String fileType) {
		this.fileType = fileType;
	}
	public String getResourceContent() {
		return resourceContent;
	}
	public void setResourceContent(String resourceContent) {
		this.resourceContent = resourceContent;
	}
	public Integer getDateline() {
		return dateline;
	}
	public void setDateline(Integer dateline) {
		this.dateline = dateline;
	}
	public String getMd5() {
		return md5;
	}
	public void setMd5(String md5) {
		this.md5 = md5;
	}
	public Integer getLastModifyTime() {
		return lastModifyTime;
	}
	public void setLastModifyTime(Integer lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}
	public Long getSchoolId() {
		return schoolId;
	}
	public void setSchoolId(Long schoolId) {
		this.schoolId = schoolId;
	}
	
	/** 视频或音频的时长（单位：秒） */
	public Integer getDuration() {
		return duration;
	}
	
	/** 视频或音频的时长（单位：秒） */
	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	public boolean isAudio() {
		if(StringUtils.isEmpty(this.fileType)) {
			return false;
		}
		return ResourceContants.FileType.AUDIO.name().equals(getFileType().toUpperCase());
	}
	public boolean isWord() {
		if(StringUtils.isEmpty(this.suffix)) {
			return false;
		}
		return ResourceContants.RESOURCE_SUFFIX_WORD.contains(this.suffix.toLowerCase());
	}
	public boolean isPPT() {
		if(StringUtils.isEmpty(this.suffix)) {
			return false;
		}
		return ResourceContants.RESOURCE_SUFFIX_PPT.contains(this.suffix.toLowerCase());
	}
	public boolean isExcel() {
		if(StringUtils.isEmpty(this.suffix)) {
			return false;
		}
		return ResourceContants.RESOURCE_SUFFIX_EXCEL.contains(this.suffix.toLowerCase());
	}
	public boolean isSwf() {
		if(StringUtils.isEmpty(this.suffix)) {
			return false;
		}
		return ResourceContants.RESOURCE_SUFFIX_SWF.equals(this.suffix.toLowerCase());
	}
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	/** 背景音乐对应的资源id，图说的资源会用到 */
	public Integer getBgMusic() {
		return bgMusic;
	}

	/** 背景音乐对应的资源id，图说的资源会用到 */
	public void setBgMusic(Integer bgMusic) {
		this.bgMusic = bgMusic;
	}

	public Integer getTransFlag() {
		return transFlag;
	}

	public void setTransFlag(Integer transFlag) {
		this.transFlag = transFlag;
	}

	public String getDownloadPower() {
		return downloadPower;
	}

	public void setDownloadPower(String downloadPower) {
		this.downloadPower = downloadPower;
	}

	public Integer getSysExtra() {
		return sysExtra;
	}

	public void setSysExtra(Integer sysExtra) {
		this.sysExtra = sysExtra;
	}

	public Integer getMdateline() {
		return mdateline;
	}

	public void setMdateline(Integer mdateline) {
		this.mdateline = mdateline;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	public String getMetainfo() {
		return metainfo;
	}

	public void setMetainfo(String metainfo) {
		this.metainfo = metainfo;
	}

	public Integer getOssServer() {
		return ossServer;
	}

	public void setOssServer(Integer ossServer) {
		this.ossServer = ossServer;
	}

	public String getOssBucket() {
		return ossBucket;
	}

	public void setOssBucket(String ossBucket) {
		this.ossBucket = ossBucket;
	}

	public String getOssTransId() {
		return ossTransId;
	}

	public void setOssTransId(String ossTransId) {
		this.ossTransId = ossTransId;
	}

	public String getOssTransKey() {
		return ossTransKey;
	}

	public void setOssTransKey(String ossTransKey) {
		this.ossTransKey = ossTransKey;
	}

	public String getOssHash() {
		return ossHash;
	}

	public void setOssHash(String ossHash) {
		this.ossHash = ossHash;
	}

	public String getPlayPath() {
		return playPath;
	}

	public void setPlayPath(String playPath) {
		this.playPath = playPath;
	}

	public String getOssPath() {
		return ossPath;
	}

	public void setOssPath(String ossPath) {
		this.ossPath = ossPath;
	}

	public Integer getPage2image() {
		return page2image;
	}

	public void setPage2image(Integer page2image) {
		this.page2image = page2image;
	}

	public boolean isHasAlreadyExists() {
		return hasAlreadyExists;
	}

	public void setHasAlreadyExists(boolean hasAlreadyExists) {
		this.hasAlreadyExists = hasAlreadyExists;
	}

	public String getOssDomain() {
		return ossDomain;
	}

	public void setOssDomain(String ossDomain) {
		this.ossDomain = ossDomain;
	}
}
